<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>商家审核</title>
<jsp:include page="../addlink.jsp" />

<style>
.resetPassword{width:60%;margin:auto;margin-top:12%;}
.resetPassword .btn{background-color: #ff4b51;border:none;line-height: 42px;color: #fff;margin: auto 50%;}
</style>
</head>
<body>
	<jsp:include page="../head.jsp" />

	<div class="container-fluid all">
		<jsp:include page="../menu.jsp" />
		<div class="maincontent">
		<div class="resetPassword form-horizontal">
		  <div class="form-group">
		    <label class="col-sm-2 control-label">旧密码</label>
		    <div class="col-sm-10">
		      <input type="password" class="form-control inputOldPassword" name="oldPassword" placeholder="请输入旧的密码">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">新密码</label>
		    <div class="col-sm-10">
		      <input type="password" class="form-control inputNewPassword1" name="newPassword" placeholder="请输入新的密码">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">确认密码</label>
		    <div class="col-sm-10">
		      <input type="password" class="form-control inputNewPassword2" name="confirmNewPassword" placeholder="请再次输入新的密码">
		    </div>
		  </div>
		  <div class="btn">确认</div>
		  </div>
		  
		</div>

	</div>


</body>
<script>
function checkForm(){
	  if($(".inputOldPassword").val()=="")
	  {
	  zxTips_short({
			txt : "请输入旧的密码"
		});
	  return false;
	  }
	  else if($(".inputNewPassword1").val()=="")
	  {
	  zxTips_short({
			txt : "请输入新的密码"
		});
	  return false;
	  }
	  else if($(".inputNewPassword2").val()!=$(".inputNewPassword1").val())
	  {
	  zxTips_short({
			txt : "新的密码输入不一致"
		});
	  return false;
	  }
	  else if($(".inputOldPassword").val()==$(".inputNewPassword1").val())
	  {
	  zxTips_short({
			txt : "新旧密码不能相同"
		});
	  return false;
	  }
	  else{
		  return true;
	  }
	  
}
  $(".resetPassword .btn").click(function(){
		if(checkForm())
		{
			var oldPassword = $("input[name=oldPassword]").val();
			var newPassword = $("input[name=newPassword]").val();
			console.log(oldPassword + "------" + newPassword);
			//return false;
			$.ajax({
				type:"POST",
				url:"${basePath}/sys/user/updatePassword",
				data:{oldPassword:oldPassword,newPassword:newPassword},
				success:function(data){
					if(checkTokenError(data)){
						if(data.code == -998){
							zxTips_short({txt:data.result});
							//alert(data.message);
						}else if(data.code == 200){
							 setTimeout(function(){
								window.location.href = "${basePath}/main"
							},1000); 
							zxTips_short({txt:data.result});
						}else if(data.code == 400){
							zxTips_short({txt:data.result});
						}
						//console.log(data.result);
						}
				}
			});
		}
  });
</script>

<jsp:include page="../foot.jsp" />

</html>
